package uriel.frankel;

import java.util.Timer;
import java.util.TimerTask;
import uriel.frankel.R;




import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class PollHelper extends Activity implements OnClickListener {

	private int X=15;
	private Button closeButton;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// Be sure to call the super class.
		super.onCreate(savedInstanceState);
		setContentView(R.layout.poll_helper);
		closeButton = (Button)findViewById(R.id.close_poll_helper);
		closeButton.setOnClickListener(this);
		Timer timer = new Timer();
		timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				
				runOnUiThread(new Runnable() {
					public void run() {
						closeButton.setText("close ("+ getX() +")");
						if(X<0){
							finish();
						}
					}
				});
			}
		}, 0, 1000);
	}

	synchronized private int getX(){
		return X--;
	}

	@Override
	public void onClick(View v) {
		finish();
		
	}
}
